<template>
    <div class="wrapper">
    <swiper :options="swiperOption" v-if="showSwiper">
    <!-- slides -->
    <swiper-slide v-for= "item of list" :key= "item.id">
        <img class="swiper-img" :src="item.imgUrl">
    </swiper-slide>
    <!-- Optional controls -->
    <div class="swiper-pagination"  slot="pagination"></div>
    <!-- 左右箭头这两个是 -->
    <!-- <div class="swiper-button-prev" slot="button-prev"></div>
    <div class="swiper-button-next" slot="button-next"></div> -->
    <!-- <div class="swiper-scrollbar"   slot="scrollbar">是一条横条</div> -->
  </swiper>
    </div>
 </template>

<script>
export default {
  name: 'HomeSwiper',
  props: {
    list: Array
  },
  data () {
    return {
      swiperOption: {
        pagination: '.swiper-pagination',
        loop: true
      }
      // swiperList: [{
      //   id: '001',
      //   imgUrl: 'http://img1.qunarzz.com/piao/fusion/1801/6e/3f6a091804ac0a02.jpg_890x330_b6673437.jpg'
      // }, {
      //   id: '002',
      //   imgUrl: 'http://img1.qunarzz.com/piao/fusion/1804/3a/074ab93899b27702.jpg_890x330_6099120e.jpg'
      // }, {
      //   id: '003',
      //   imgUrl: 'http://img1.qunarzz.com/piao/fusion/1802/5d/777b4ba55b4d0802.jpg_890x330_bd7b1e5d.jpg'
      // }, {
      //   id: '004',
      //   imgUrl: 'http://img1.qunarzz.com/piao/fusion/1804/97/097b9aa3b6815302.jpg_890x330_a74265fc.jpg'
      // }]
    }
  },
  computed: {
    showSwiper () {
      return this.list.length
    }
  }
}
</script>

<style lang="stylus" scoped>
  .wrapper
    width:100%
    height: 0
    overflow: hidden
    padding-bottom: 35%
    .swiper-img
      width: 100%
</style>
